package pay

import "errors"

// 支付工厂 用于统一处理支付请求

// 支付渠道
type PaymentChannel string

const (
	PaymentChannelAlipay   PaymentChannel = "alipay"
	PaymentChannelWechatPay PaymentChannel = "wechatpay"
)

// 支付工厂
type PaymentFactory struct {
}

// NewPaymentFactory 新建支付工厂
func NewPaymentFactory() *PaymentFactory {
	return &PaymentFactory{}
}

// CreatePayment 创建支付网关
func (f *PaymentFactory) CreatePayment(channel PaymentChannel) (PaymentGateway, error) {
	switch channel {
	case PaymentChannelAlipay:
		return NewAlipayAdapter("app_id_123321", "app_secret_123321"), nil
	case PaymentChannelWechatPay:
		return NewWechatAdapter("mch_id_123321", "api_key_123321"), nil
	default:
		return nil, errors.New("unsupported payment type")
	}
}
